import lejos.robotics.subsumption.Behavior;

public class DoSquare implements Behavior 
{	
//	private TouchSensor touch;
//	private UltrasonicSensor sonar;
	private MapMaker mm = null;
	
	public DoSquare(MapMaker mm)
	{
		this.mm = mm;
//		this.touch = mm.collisionDetector;
//	    this.sonar = mm.eyes;	    
	}

	public boolean takeControl()
	{
			 
	    return true;
	 }

	  public void suppress() 	  {  } // Para ja nao utilizado

	  // Avoid the obstacle by turning to its left
	  public void action()
	  {		
	//	 mm.snav.travel(-10.0F);
	//	mm.leftMotor.rotate(-300, true);//
	//	do	{ mm.UpdatePose(); }	while(mm.leftMotor.isMoving() );		
	//	mm.rightMotor.rotate(-300, true );
	//	do	{ mm.UpdatePose(); }	while(  mm.snav.isMoving() );
		 mm.UpdatePose();
		 mm.snav.travel(10);
		 mm.UpdatePose();
		 mm.snav.rotate(90 , false);
		 mm.UpdatePose();
		 mm.snav.travel(10);		  
		 mm.UpdatePose();
		 mm.snav.rotate(90 , false);
		 mm.UpdatePose();
		 mm.snav.travel(10);		  
		 mm.UpdatePose();
		 mm.snav.rotate(90 , false);
		 mm.UpdatePose();
		 mm.snav.travel(10);		  
		 mm.UpdatePose();
		 
	//	mm.leftMotor.rotate(-360, true);//
	  //  do	{ mm.UpdatePose(); }	while(mm.leftMotor.isMoving());
	 //   mm.rightMotor.rotate(360, true );  
	//    do	{ mm.UpdatePose(); }	while(mm.leftMotor.isMoving() || mm.rightMotor.isMoving() );
	    //do	{  }	while( mm.snav.isMoving() );
		// mm.UpdatePose();
	  
	  }
}
